home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / POKER.TST / POKRPROB.C < prev    next >
C/C++ Source or Header  |  1995-11-12  |  1KB  |  36 lines

  1. /* ============ */
  2. /* pokrprob.c    */
  3. /* ============ */
  4. #include <defcodes.h>
  5. #include <miscdefs.h>
  6. #include <mconf.h>
  7. /* ==================================================================== */
  8. /* CalcPokerProbs - Calculates Five Probabilities for Poker Test    */
  9. /* ==================================================================== */
  10. void
  11. CalcPokerProbs(int HandSize, int DVal, double *PokerProbVals)
  12. {
  13.     int     r;
  14.     int     i;
  15.     double  DkPow;
  16.  
  17.     /* ---------------------------------------------------------------- */
  18.     /* HandSize         -    Number of Cards in a Hand            */
  19.     /* DVal         -    Value of Data Width                    */
  20.     /*            Range of Variates is (0, DVal-1)        */
  21.     /* PokerProbVals -    Probabilities Associated with Each Type of Hand    */
  22.     /*            There will be HandSize of These            */
  23.     /* ---------------------------------------------------------------- */
  24.     DkPow = powi((double) DVal, HandSize-1);
  25.  
  26.     for (r = 1; r <= HandSize; ++r)
  27.     {
  28.     PokerProbVals[r - 1] = (double)Stirling2(HandSize, r) / DkPow;
  29.  
  30.     for (i = DVal - 1; i >= DVal + 1 - r; --i)
  31.     {
  32.         PokerProbVals[r - 1] *= i;
  33.     }
  34.     }
  35. }
  36.